﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

#pragma once
#include "GmepModelInterface.h"
#include "IMepInstance.h"

namespace gmep
{
    enum class FittingPartType;
    enum class MEPDisciplineId;
    class IMepFittingType;
    class IConnectorManager;

    ///brief:机电构件类
    class GMEP_MODEL_INTERFACE_EXPORT IMepFitting : public IMepInstance
    {
        DEFINE_CAST_DERIVED(gmep::IMepFitting,gmep::IMepInstance)
    public:
        virtual ~IMepFitting() {}

        /// \brief 获得管件的零件类型
        FittingPartType GetFittingPartType() const;

        /// \brief 得到Const构件类型指针
        /// \return 构件类型指针
        const IMepFittingType * GetMepFittingType() const;

        /// \brief 得到管件件类型指针
        /// \return 管件类型指针
        IMepFittingType * GetMepFittingType();

        /// \brief 得到管件的系统Id
        /// \return 管件的系统Id
        virtual gcmp::ElementId GetMepSystemId() const override;

        /// \brief 获取管件所属的专业
        /// \return 返回管件所属的专业
        virtual gmep::MEPDisciplineId GetMepDiscipline() const = 0;

        /// \brief 获取所在视图对象Id
        /// 
        /// 当创建视图对象管件时，视图对象Id为有效值，否则为无效值。
        /// \return 所在视图对象Id
        virtual gcmp::ElementId GetModelViewId() const = 0;

        /// \brief 获取延迟驱动参数计算器的RegionDataId
        ///
        /// \目前仅对水管、风管和线管的变径有效
        /// \return 延迟驱动参数计算器的RegionDataId
        virtual RegenDataId GetShouldUpdateDriveParameterLaterRdId() const = 0;

        /// \brief 得指管件隔热层对象Id 
        /// \return 管件隔热层对象Id
        virtual gcmp::ElementId GetMepFittingInsulationId()const = 0;

        /// \brief 得到连接点管理器指针
        /// \return 连接点管理器指针
        virtual const IConnectorManager *GetConnectorManager() const = 0;

        /// \brief 得到连接点管理器指针
        /// \return 连接点管理器指针
        virtual IConnectorManager *GetConnectorManager() = 0;

        /// \brief 设置管件隔热层对象Id 【相关功能还未实现】
        /// \param mepFittingInsulationId 隔热层对象Id
        /// \return 返回true表示设置成功，否则表示失败
        virtual bool SetMepFittingInsulationId(const gcmp::ElementId& mepFittingInsulationId) = 0;

        //以下是IExternalData需要重写的接口，为平台调用接口，外部禁止手动调用
    protected:
        virtual void UpdateForWeakParentDeletion(const std::set<gcmp::ElementId>& deletedElementIds)  override;
        virtual void ReportParents(gcmp::IElementParentReporter& reporter) const override;
        virtual void Report(const gcmp::ICopyContext & copyContext, gcmp::ICopyStrategyReporter& reporter) const override;

        virtual void ReportParameterDefinitions(std::vector<int>* pParameterIds) const override {}
        virtual gcmp::OwnerPtr<gcmp::IParameter> GetNativeParameter(int parameterId) const override;
        virtual bool SetNativeParameter(const gcmp::IParameter *pParameter, std::wstring* errorMsg = nullptr) override { return false; }
        virtual bool IsParameterModifiable(int parameterId) const override { return true; }
        virtual void UpdateAfterCopy(const gcmp::ICopyContext& copyContext) override {}
        virtual void UpdateForWeakParentCopied(
            const gcmp::IDocument* pDocumentFrom,
            const gcmp::IElement* pSource,
            const gcmp::IElement* pCopy
        ) const override {}
        virtual bool ShouldBeCopiedTogether(const gcmp::ICopyContext & copyContext) const override { return true; }
        virtual bool IsStrongParentsNeedCopied(void) const override { return true; }
        virtual bool CanBeCopied(std::wstring* pErrorMessage) const override { return true; }
        virtual bool Transform(const gcmp::Matrix4d& matrix) override { return true; }
    };
}
